package Solution151_175;

import org.junit.Test;

public class Solution165比较版本号 {
    public int compareVersion(String version1, String version2) {
        String[] ver1=version1.split("\\.");
        String[] ver2=version2.split("\\.");
        int maxLength=Math.max(ver1.length,ver2.length);
        for(int i=0;i<maxLength;i++){
            int value1=i>=ver1.length?0:Integer.parseInt(ver1[i]);
            int value2=i>=ver2.length?0:Integer.parseInt(ver2[i]);
            if(value1>value2){
                return 1;
            }else if(value1<value2){
                return -1;
            }
        }
        return 0;
    }

    @Test
    public void test(){
        compareVersion("0.1","1.1");
    }
}
